/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package loginbeans;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Ara Yeritsian
 */
@ManagedBean
@SessionScoped
public class login implements Serializable{

    private String userName;
    private String password;  
    private String error;
    private boolean isLoggedin;
    
    public login() {
        isLoggedin=false;
    }
    
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }   
    
    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }
    
    public boolean isIsLoggedin() {
        return isLoggedin;
    }

    public void setIsLoggedin(boolean isLoggedin) {
        this.isLoggedin = isLoggedin;
    }
    
    public String validate(){
        if(userName.equals("Ara") && password.equals("root")){
            isLoggedin=true;
            return "success";
        }
        error="User name and/or password is wrong!";
        return "fail";
    }
    
    public String logout(){
        isLoggedin = false;
        return "logout";
    }
}
